<template>
  <div>
    <div v-if=" commodityInfo && commodityInfo.lastStockCountNum >0 "
         class="aui-btn aui-btn-danger aui-btn-sm add_to_cart"
         style="padding:0 0.7rem;height: 100%;bottom: 0;position:absolute;z-index: 1;right: 0;line-height: 3rem;font-size:1rem;border-radius: 0"
         @click="showCartModle">
      加入购物车
    </div>
    <div v-if="commodityInfo.lastStockCountNum <= 0"
         class="aui-btn aui-btn-sm add_to_cart"
         @click="showCartModle"
         style="color:white;background: #ddd ;height: 100%;bottom: 0;position:absolute;z-index: 1;right: 0;line-height: 3rem;font-size: 1rem;border-radius: 0;padding:0 0.7rem;">
      已售罄
    </div>

    <!-- <cart-mode ref="cartModle" buttonText="确 定" @isClossing="updateCart" :height="'18rem'">
      <add-cart-for-proce v-if="commodityInfo" ref="addCartForProce"
                          :commodityInfor="commodityInfo">
      </add-cart-for-proce>
    </cart-mode> -->
  </div>
</template>

<script>
  // import Hello from './components/Hello'
  import {mapState, mapGetters} from 'vuex'
  import CartMode from '../CartMode';
  import AddCartForProce from '../AddCartForProce'
  import UpdateCart from '../UpdateCart'
  import {translateDetailData, getLastStockCountNum} from '@/utils/TranslateDetailDate';
  import getConfig from '@/utils/CJY/getConfig';
  import { openApp } from '../../utils/ZWY/utils.js'
  export default {
    data() {
      return {
        workingInfo: null
      }
    },
    props: {
      goodsInfo: {
        type: Object,
        default: () => ({})
      },
      goApp: {
        default: () => {}
      }
    },
    components: {CartMode, AddCartForProce},
    methods: {
      translateDetailData,
      showCartModle() {
        this.goApp();
      },

      async getWorkingInfo() {
      },

      updateCart() {
        this.$refs.addCartForProce && this.$refs.addCartForProce.updateCart()
      },
    },


    computed: {
      ...mapGetters({
        userInfo: 'xhModules/userInfo',
        sessionId: 'xhModules/sessionId',
      }),
      ...mapGetters(['cartConfig', 'storeConfigStatus']),
      goodsTrolleyType() {
        var getConfigParams = this.cartConfig || {}
        return getConfigParams.goodsTrolleyType || 0
      },
      commodityInfo() {
        return translateDetailData(this.goodsInfo)
      }
    }
  }
</script>

<style>

</style>
